<?php
namespace app\admin\model\operating;
use think\facade\Db;
use app\admin\common;

class Version{
	public function findVersion($_where,$_field){
		extract(common::get('app_version',[$_where,$_field]));
		if(empty($data)){
			$data=Db::name("app_version")->where($_where)->field($_field)->find();
			common::set($data);
		}
		return $data;
	}
	
	public function selectVersion($_where,$_field,$_limit,$_order){
		extract(common::get('app_version',[$_where,$_field,$_limit,$_order]));
		if(empty($data)){
			$_data=Db::name("app_version")->where($_where)->field($_field)->limit(reset($_limit),end($_limit))->order($_order)->select();
			common::set($data);
		}
		return empty($_data)?:$_data->toArray();
	}
	
	public function upVersion($_up,$_where){
		common::delete('app_version');
		return Db::name("app_version")->where($_where)->update($_up);
	}
	
	public function addVersion($_data){
		common::delete('app_version');
		return Db::name("app_version")->insert($_data,true);
	}
}
?>